<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [
            "one",
            "two",
            "three",
            "four"
        ]

        // 找到数组中值相等的元素并返回，如果找不到返回undefined;
        let val = arr.find(function(item){
            return item === "two";
        })
        
        console.log(val); //two

        // 找到含有对应值的元素下标，如果找不到就返回-1；
        // let index = arr.findIndex(function(item){
        //     // console.log(item);  //执行4次
        //     return item === "five";
        // });

        // console.log(index); //-1

       


    </script>
</body>
</html>